﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ModelManager
{


    private Dictionary<System.Type, BaseModel> Models = new Dictionary<System.Type, BaseModel>();

    public T NewGet<T>() where T : BaseModel, new()
    {

        if (!Models.ContainsKey(typeof(T)))
        {
            Models[typeof(T)] = new T();
        }
        return (T)Models[typeof(T)];
    }


    public T Get<T>() where T : BaseModel
    {
        if (!Models.ContainsKey(typeof(T)))
        {
            return null;
        }
        return (T)Models[typeof(T)];
    }

    public void Destory<T>() where T : BaseModel
    {
        if (Models.ContainsKey(typeof(T)))
        {
            Models.Remove(typeof(T));
        }
    }




}
